package fr.formation.data;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ResourceBundle;
import java.util.logging.Logger;

import javax.sql.DataSource;

/**
 * La Classe DataSourceAtod test.
 */
public class DataSourceAtod implements DataSource {

    /*
     * 
     */
    @Override
    public Connection getConnection() throws SQLException {
        Connection cnx = null;
        ResourceBundle ressources = ResourceBundle.getBundle("db");
        try {
            Class.forName(ressources.getString("jdbcDriver"));
            cnx = DriverManager.getConnection(
                    ressources.getString("url"),
                    ressources.getString("username"),
                    ressources.getString("password"));
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return cnx;

    }

    /* ()
     * @see javax.sql.CommonDataSource#getLogWriter()
     */
    @Override
    public PrintWriter getLogWriter() throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    /* ()
     * @see javax.sql.CommonDataSource#getLoginTimeout()
     */
    @Override
    public int getLoginTimeout() throws SQLException {
        // TODO Auto-generated method stub
        return 0;
    }

    /* ()
     * @see javax.sql.CommonDataSource#getParentLogger()
     */
    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        // TODO Auto-generated method stub
        return null;
    }

    /* ()
     * @see javax.sql.CommonDataSource#setLogWriter(java.io.PrintWriter)
     */
    @Override
    public void setLogWriter(PrintWriter pArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    /* ()
     * @see javax.sql.CommonDataSource#setLoginTimeout(int)
     */
    @Override
    public void setLoginTimeout(int pArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    /* ()
     * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
     */
    @Override
    public boolean isWrapperFor(Class<?> pArg0) throws SQLException {
        // TODO Auto-generated method stub
        return false;
    }

    /* ()
     * @see java.sql.Wrapper#unwrap(java.lang.Class)
     */
    @Override
    public <T> T unwrap(Class<T> pArg0) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }



    /* ()
     * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)
     */
    @Override
    public Connection getConnection(String pArg0, String pArg1) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

}
